package com.za.wbw.util;


import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;

import com.opensymphony.xwork2.ActionSupport;


public class BaseAction extends ActionSupport implements ServletRequestAware, ServletResponseAware {
	public static Logger logger = Logger.getLogger(BaseAction.class);
	
	private static final long serialVersionUID = 1L;

	
    public HttpServletRequest request;

    public HttpServletResponse response;

    private PrintWriter getOutPrint() throws Exception {
    	response.setContentType("text/html;charset=gbk");
        return response.getWriter();
    }
    public void outPrint(Object obj) throws Exception {
        PrintWriter out = getOutPrint();
        try {
            if (out != null) {
            	out.print(obj);
            }
        } catch (Exception e) {
            throw e;
        } finally {
            if (out != null) {
                out.flush();
                out.close();
                out = null;
            }
        }
    }
	@Override
	public void setServletResponse(HttpServletResponse arg0) {
		this.response = arg0;
	}

	@Override
	public void setServletRequest(HttpServletRequest arg0) {
		this.request = arg0;
	}
}
